package com.hmdp.receiver;

import com.hmdp.entity.VoucherOrder;
import com.hmdp.service.IVoucherOrderService;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class OrderReceiver {
    @Resource
    private IVoucherOrderService voucherOrderService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "queue.order",durable = "true"),
            exchange = @Exchange("exchange.order"),
            key ={"routing.order"}
    ))
    public void createOrder(VoucherOrder voucherOrder){
        voucherOrderService.handleVoucherOrder(voucherOrder);
    }
}
